#pragma once

#include "common/common.h"
#include "ipc/imutualexclusionlock.h"
#include "ipc/cthreadmutex.h"

using namespace PILO::Core::IPC;

namespace PILO 
{
    namespace Core
    {
        namespace IPC 
        {
            class CAutoMutexLocker
            {
            public:
                CAutoMutexLocker(IMutualExclusionLock* lock) : _m_lock(lock)
                {
                    _m_lock->lock();
                }
                ~CAutoMutexLocker()
                {
                    _m_lock->unlock();
                }

                void reLock()
                {
                    _m_lock->lock();
                }

                void unlock()
                {
                    _m_lock->unlock();
                }

            protected:
                IMutualExclusionLock*   _m_lock;

            };
        }
    }
}
